package com.im.controller;


import com.im.dao.AdminDao;
import com.im.pojo.ImUser;
import com.im.pojoClass.Result;
import com.im.pojoClass.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@Api(tags = {"后台管理"}, value = "AdminController")
@RestController
@RequestMapping("/admin")
@CrossOrigin
public class AdminController {

    @Autowired
    private AdminDao adminDao;

    /******************************************************************************************************/
    @ApiOperation(value = "添加用户表", notes = "返回影响行数")
    @RequestMapping(value = "/insertUser", method = RequestMethod.POST)
    public Result insertUser(String user_id, String user_pass, String user_name, String user_img) {
        Integer imUser = adminDao.insertUser(user_id, user_pass, user_name, user_img);
        return new Result(ResultCode.SUCCESS, imUser);
    }

//    /******************************************************************************************************/
//    @ApiOperation(value = "删除用户表", notes = "返回影响行数")
//    @RequestMapping(value = "/deleteUser", method = RequestMethod.POST)
//    public Result deleteUser(String user_id) {
//        Integer imUser = adminDao;
//        return new Result(ResultCode.SUCCESS, imUser);
//    }

    /******************************************************************************************************/
    @ApiOperation(value = "查询用户表", notes = "返回用户表数据")
    @RequestMapping(value = "/selectUser", method = RequestMethod.GET)
    public Result selectUser() {
        ArrayList<ImUser> imUser = adminDao.selectUser();
        return new Result(ResultCode.SUCCESS, imUser);
    }

}